<#-- @ftlvariable name="entity" type="com.xci.edu.core.entity.ExamPaper" -->
<#include "/sys/_layout.ftl">
<!doctype html>
<html>
<head>
    <@pageHeader/>
</head>
<body>
<@pageLoading/>
<div id="gridtoolbar">
    <form id="gridform" class="jxlayout-form form-inline jxform">
<#--        <div class="form-group">-->
<#--            <select class="form-control jxselect" name="eduCategoryId" data-text-field="eduCategoryName"-->
<#--                    data-allow-clear="true">-->
<#--                <option></option>-->
<#--                <@eduCategorySelectOption selectedValue=entity.eduCategoryId></@eduCategorySelectOption>-->
<#--            </select>-->
<#--        </div>-->
        <div class="form-group">
            <select name="questionCategory" class="jxselect form-control" data-select-submit="true" data-width="140" data-allow-clear="false">
                <option value=" " selected>全部题型</option>
                <@questionCategoryOptions />
            </select>
        </div>
        <button class="btn btn-primary ml-5" type="submit">
            <i class="fa fa-search"></i> 查询
        </button>
            <a class="btn btn-default" onclick="batchSave()">
                <i class="icon-plus"></i> 批量添加
            </a>
    </form>
</div>
<table id="grid" data-options="form:'#gridform',toolbar:'#gridtoolbar'">
    <thead>
    <tr>
        <input id="paperId" hidden value="${paperId}">
        <th data-options="field:'ck',checkbox:true"></th>
        <th data-options="title:'试题题干',field:'title',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'试题类型名称',field:'questionCategoryName',width:100,align:'left',sortable: false"></th>
        <th data-options="title:'科目名称',field:'eduCategoryName',width:100,align:'left',sortable: false"></th>
        <th data-options="title:'选项A',field:'optionA',width:100,align:'left',sortable: false"></th>
        <th data-options="title:'选项B',field:'optionB',width:100,align:'left',sortable: false"></th>
        <th data-options="title:'选项C',field:'optionC',width:100,align:'left',sortable: false"></th>
        <th data-options="title:'选项D',field:'optionD',width:100,align:'left',sortable: false"></th>
        <th data-options="title:'选项E',field:'optionE',width:50,align:'left',sortable: false"></th>
        <th data-options="title:'选项F',field:'optionF',width:50,align:'left',sortable: false"></th>
        <th data-options="title:'答案',field:'answer',width:100,align:'left',sortable: false"></th>
        <th data-options="title:'答案解析',field:'answerResolve',width:200,align:'left',sortable: false"></th>
        <th data-options="title:'分值',field:'score',width:50,align:'left',sortable: false"></th>
        <th data-options="title:'备注',field:'remark',width:100,align:'left',sortable: false"></th>
    </tr>
    </thead>
</table>
<@pageFooter/>
<script>
    jx.ready(function () {
        window.curd = new jx.GridCurd('#grid', {
            title: '试题库',
            dialogWidth: '800px',
            dialogHeight: '600px',
            api: {
                grid: '/background/eduQuestion/grid',
                saveQuestions : '/background/examPaper/saveQuestions'
            },
            onInit: function (instance) {

            }
        });
    });

    /**
     * 批量添加试题
     */
    function batchSave(){
        var paperId = document.getElementById("paperId").value;
        if (!curd.gridInstance.hasCheckedRow()) return;
        var ids = curd.gridInstance.getCheckedRowIds();
        jx.ajax({
            url: jx.url(curd.api.saveQuestions),
            data: {
                paperId: paperId,
                ids: ids.join()
            },
            maskMsg: '正在添加,请稍等...',
            success: function (result) {
                this.reloadGridData();
                jx.toastr.success('添加成功');
            }
        });
    }
</script>
</body>
</html>
